#ifndef Trace_h__
#define Trace_h__

#include "JME_GLog.h"

#define TRACE_FUNCTION
#ifdef TRACE_FUNCTION

class FunctionLog final
{
public:
	FunctionLog(const char* func):
		_func(func)
	{
		LogT << "Function " << _func << " begin" << LogEnd;
		_startTime = boost::get_system_time();
	}
	~FunctionLog()
	{
		boost::system_time endTime = boost::get_system_time();
		int elapse = (int)(endTime - _startTime).total_milliseconds();
		LogT << "Function " << _func << " end, consume " << elapse << " msg" << LogEnd;
	}
private:
	const char* _func;
	boost::system_time _startTime;
};

#define FUNCTIONLOG \
	auto log = FunctionLog(__FUNCTION__);

#else

#define FUNCTIONLOG

#endif

#endif // Trace_h__
